home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / program / qbasix.zip / Qbasix.man < prev    next >
Text File  |  1997-07-13  |  19KB  |  447 lines

  1.  
  2.          ┌───────────────────────────────────────┐
  3.          │▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ QBASIX 2 ▒▒▒▒▒▒▒▒▒▒▒▒▒▒│
  4.          ├───────────────────────────────────────┤
  5.          │          QBASIc eXtender         │
  6.          │         version 2         │
  7.          │  an external TSR library for QBasic     │
  8.          └───────────────────────────────────────┘
  9.  
  10.  
  11.     0. Legal issues
  12.     ---------------
  13.  
  14.                  Freeware
  15.  
  16.     QBASIX is copyrighted software which is distributed as
  17.     freeware.
  18.  
  19.     You are free to use this this software and to pass copies of it
  20.         on to others as long as it is not for payment and not bundled
  21.         with anything else that is for payment.
  22.  
  23.  
  24.  
  25.                 Disclaimer
  26.  
  27.     Use of this programming package acknowledges this disclaimer of
  28.     warranty:
  29.     "This program is supplied as is. Hans Lunsing disclaims all
  30.     warranties, express or implied, including, without limitation,
  31.     the warranties of merchantability and of fitness of this program
  32.     for any purpose. Hans Lunsing assumes no liability for damages
  33.     direct or consequential, which may result from the use of this
  34.     program."
  35.  
  36.                 Trademarks
  37.  
  38.     All trademarks and copyrights belong to their respective holders.
  39.  
  40.  
  41.     1. Why QBASIX ?
  42.     ---------------
  43.  
  44.     QBASIC is a very useful instrument for those who want to get
  45.     something more from their computer than only DOS is able to
  46.     offer. Thank to its powerful development environment it is very
  47.     easy to just build and execute a small program for a job
  48.     otherwise a specialized program should have to be used for.
  49.  
  50.     Besides small throw-away programs you can also make bigger, well
  51.     structured programs with it. With QBASIC Microsoft provides some
  52.     example programs showing that very well. For that matter it is a
  53.     match for the latest versions of the QuickBASIC compiler and
  54.     development environment, 4 and 4.5.
  55.  
  56.     However, QuickBASIC is not for free as QBASIC, and that is
  57.     apparent from the extra features QuickBASIC offers. For
  58.     instance, QuickBasic can be extended easily with all sorts of
  59.     external commands, which are included in so called libraries.
  60.     Microsoft itself provides such a, allthough very small, library
  61.     with QuickBASIC, including a routine with the help of which many
  62.     different system functions can be performed: InterruptX, an
  63.     extremely powerful addition to the language.
  64.  
  65.     It is a great pity that QBASIC must do without this. Isn't there
  66.     nothing to do about it?     Well, it is!  That small library for
  67.     QuickBASIC also includes the command CALL ABSOLUTE, and
  68.     Microsoft has been so nice to bring it within reach of QBASIC
  69.     users as an internal command of QBASIC. For QuickBASIC it really
  70.     is a completely redundant command but for QBASIC it forms the
  71.     back door to all sorts of beautiful extensions of the language,
  72.     such as the already mentioned InterruptX.
  73.  
  74.     Here QBasiX TSR gets on the stage. By way of CALL ABSOLUTE it
  75.     provides QBASIC users with a number of powerful instruments, not
  76.     implemented in QBASIC itself.
  77.  
  78.  
  79.     2. What QBASIX offers you
  80.     -------------------------
  81.  
  82.     You will ask yourself now without doubt what one can do with
  83.     QBasiX TSR then and if there is something for you in it. To
  84.     quickly satisfy your curiosity here follows an overview of all
  85.     possible instruments QBasiX TSR has to offer.
  86.  
  87.     - Performing DOS- and other system functions.
  88.     QBasiX TSR has a command InterruptX for performing system
  89.     functions, which can be used in the same way as the InterruptX
  90.     command of QuickBasic. In addition there is a shortened version
  91.     for MSDOS functions.
  92.  
  93.     - Getting and setting a command line.
  94.     QBasiX TSR offers the possibility to provide a command line for
  95.     the program at QBASICs startup, just as with QuickBASIC, after
  96.     which it can be read out in the program. In the immediate window
  97.     it can be easily changed for testing purposes.
  98.  
  99.     - Setting a termination code (error level).
  100.     QBasiX TSR offers the possibility to set an error level before
  101.     termination of QBASIC, which can be tested afterwards in a batch
  102.     program with the IF [NOT] ERRORLEVEL command.
  103.  
  104.     - Reading, scanning and writing memory.
  105.     QBasiX TSR has a number of commands which make processing memory
  106.     easier and faster than is possible with QBASICs PEEK and POKE
  107.     only. You can copy parts of the memory contents, scan it for a
  108.     text string, peek a text string and peek or poke an integer
  109.     value.
  110.  
  111.     - Getting information about the video system
  112.     Some of QBasiX TSR' commands provide you with useful information
  113.     about your video system, such as the type of video card, color
  114.     or black-and-white screen, de screen mode, the number of screen
  115.     rows and columns, the screen color in DOS etc.
  116.  
  117.     - Getting and setting some video attributes.
  118.     You can find out if blinking text is enabled and enable or
  119.     disable it. When you disable blinking text you can use bright
  120.     background colors in your programs!  With that QBASIX has a
  121.     replacement for the COLOR command, making it easier to set
  122.     bright background colors. In addition QBASIX let you find out
  123.     the current combination of text and background colors.
  124.  
  125.     - Processing the contents of the screen.
  126.     QBasiX TSR provides you with a very useful command to fill a screen
  127.     window with a certain character and/or a text color and/or a
  128.     background color. In addition to it there are commands to save
  129.     the contents of the entire screen or a screen window and to
  130.     restore them again later.
  131.  
  132.     - Testing if the printer is ready for use.
  133.     QBasiX TSR has a function for testing if the printer is ready for
  134.     use. If not, then you can trace the cause of that with the help
  135.     of the printer status reported as well.
  136.  
  137.     - Processing integer variables.
  138.     QBasiX TSR lets you shift the bits of an integer variable. You can
  139.     manipulate the two bytes of an integer in different ways, and
  140.     you can establish easily which of two integers has the highest
  141.     or lowest value.
  142.  
  143.     Most of these commands are written in fast and tight assembler
  144.     code. Because they are loaded in memory outside QBASIC they
  145.     don't seize the valuable memory provided by QBASIC to your
  146.     program. With every assembler routine goes a basic interface
  147.     routine with an obvious name which by means of CALL ABSOLUTE
  148.     takes care of its execution. To be able to use an assembler
  149.     routine you have to include its interface routine in your
  150.     program.
  151.  
  152.     The other commands are short routines written in basic, which
  153.     have to be included in your program normally if you want to use
  154.     them. A number of those use QBasiX TSR' assembler routines by
  155.     calling the interface routine going with it. Consequently this
  156.     interface routine has to be included in your program, although
  157.     you don't use it directly.
  158.  
  159.  
  160.     3. How to use QBASIX ?
  161.     ----------------------
  162.  
  163.     The assembler routines of QBasiX TSR - those to be called by
  164.     means of CALL ABSOLUTE - are being loaded in memory by means of
  165.     a separate program, QBASIX.EXE. Of course that has to be done
  166.     before you are going to use it in QBASIC. You could include the
  167.     command QBASIX for instance in your AUTOEXEC.BAT file.
  168.  
  169.     Once loaded in memory QBasiX TSR has a size of about 2,2 Kb. If
  170.     you have MSDOS 5 or higher it is possible to load QBasiX TSR
  171.     high, so that it does not seize memory for use by programs. For
  172.     that purpose issue the command
  173.  
  174.     QBASIX /h
  175.  
  176.     You can also do it with LOADHIGH, but in that case QBasiX TSR
  177.     needs more memory space, that is about 10 Kb, for starting up.
  178.     If a free block of that size is not available loading QBasiX TSR
  179.     high will not succeed, although maybe QBasiX TSR would fit well
  180.     in one of the free blocks. So preferably use QBASIX /h.
  181.  
  182.     It is not possible to load a second copy of QBasiX TSR by
  183.     accident. If a copy of QBasiX TSR is already in memory the
  184.     program will recognize that and refuse to load again.
  185.  
  186.     You can also unload QBasiX TSR from memory again. To do so issue
  187.     the command
  188.  
  189.     QBASIX /u
  190.  
  191.     If you did load further programs in memory after QBASIC, it
  192.     may not be able to erase itself from memory.
  193.  
  194.     Once loaded QBasiX TSR is ready for use. For the CALL ABSOLUTE
  195.     however you need its address in memory. When QBasix TSR has
  196.     ensconced itself in memory it reports the address it has got on
  197.     screen. Now it would of course be very inconvenient if you
  198.     should have to note that address all the time to be able to use
  199.     it afterwards in your program. Fortunately something is done
  200.     about that.
  201.  
  202.     In the QBASIX package you will find a file QBASIX.BAS. Its
  203.     contents constitute a shell in which you can develop your own
  204.     program. It includes a function named IsQBasix, which determines
  205.     if QBasiX TSR is loaded and, if so, passes its address to the
  206.     interface routines. This function is used in a programming
  207.     framework that looks broadly as follows:
  208.  
  209.     IF NOT IsQBasix THEN
  210.       PRINT "<error message>"
  211.     ELSE
  212.       ......
  213.     END IF
  214.     END
  215.  
  216.     Your own program has to be filled in at the place of the dots.
  217.  
  218.     The interface routines require the memory address of QBasiX TSR
  219.     to trace the assembler routines, but of course they must also be
  220.     able to indicate which assembler routine they want to get
  221.     executed. Tot that end all assembler routines got a number,
  222.     assigned to a constant with a obvious name. That name is similar
  223.     as much as possible to the name of the interface routine in
  224.     which it is used, preceded by a "c" (of "constant"). These
  225.     constants you will find in QBASIX.BAS also.
  226.  
  227.     It is important that QBASIX.BAS begins with the basic command
  228.  
  229.     DEFINT A-Z
  230.  
  231.     The result of this command is that all variables, not explicitly
  232.     having a type indication ($, %, &, !, #) in their name or being
  233.     declared in a DIM command as of a certain type, are considered
  234.     integers by QBASIC. Integers can be processed by the CPU much
  235.     faster than floating point variables, the type of which is the
  236.     default when no DEFINT or similar command is issued. Moreover
  237.     they require much less machine instructions, resulting in more
  238.     space in your program for other things.
  239.  
  240.     In order not to reserve memory for routines you don't use at all
  241.     QBASIX' basic routines are included in a separate procedure file
  242.     named QBASIX.PRO. From this you only have to copy the routines
  243.     you really use. Pay attention to the fact that when using
  244.     certain routines one or more of the other routines are required
  245.     as well. Also do not forget to copy the declarations of
  246.     variabele types and constants going with them. In every routine
  247.     a comment indicates if QBasiX TSR assembler routines are used
  248.     and by consequence QBASIX.EXE has to be loaded. It also
  249.     indicates which other basic routines and variable types have to
  250.     be included in your program to be able to use the routine at
  251.     hand.
  252.  
  253.     Some new variable types are defined in QBASIX.PRO, They are:
  254.  
  255.     VideoType    The elements of this type refer to the video
  256.             configuration. The required information is
  257.             supplied by the GetVideoInfo routine
  258.  
  259.     RegTypeX    The elements of this type represent the relevant
  260.             registers. This type is necessary when using the
  261.             InterruptX and MSDOS interface routines. It is
  262.             equal to the type of the same name defined by
  263.             Microsoft in QB.BI.
  264.  
  265.     In addition to these, aside from the numbers of the assembler
  266.     routines, a number of constants are defined. Two of them (TRUE
  267.     and FALSE) are generally applicable, the other ones are useful
  268.     when using certain routines. In the comment going with those
  269.     routines your attention is drawn to them.
  270.  
  271.     In case you only use routines not requiring QBASIX.EXE, you
  272.     of course don't need the program framework included in
  273.     QBASIX.BAS as well.
  274.  
  275.  
  276.     4. Using QBASIX with QuickBasic 4.0 and 4.5
  277.     -------------------------------------------
  278.  
  279.     QBasiX TSR can be used with QuickBasic 4.0 or 4.5 as well. In
  280.     that case start QB with the QBABS quick library enclosed in the
  281.     QBASIX package, as follows:
  282.  
  283.     QB /L QBABS
  284.  
  285.     or with any other quick library including CALL ABSOLUTE. An
  286.     example is QB.QLB, shipped by Microsoft with QuickBasic 4.0 and
  287.     4.5. If you use that one, you have their InterruptX procedure as
  288.     well, so you do not have use QBASIX' routine of the same name.
  289.  
  290.     The commands for reading and changing the command line are not
  291.     necessary in QB because QB already provides these possibilities
  292.     itself.
  293.  
  294.  
  295.     5. Something about segmented addresses
  296.     --------------------------------------
  297.  
  298.     To several subroutines and functions a segmented address must be
  299.     passed as a parameter. A segmented address points to a location
  300.     in memory. When used in BASIC it mostly will be the location of
  301.     a BASIC variable, but other memory locations can be referenced
  302.     as well. Somewhere at the bottom of memory for instance the BIOS
  303.     uses an area to store all sorts of information with respect to
  304.     the satellite devices. Of course it is not advisable to make
  305.     changes in the contents of memory outside the data area of the
  306.     BASIC program, but reading it will be quite harmless.
  307.  
  308.     Returning to the segmented address: it consists of two parts, a
  309.     segment value and a matching offset value. A segment is a part
  310.     of memory 64 Kb in size that begins at an absolute address (with
  311.     respect to the start of memory), that is a multiple of 16. Such
  312.     an address also is called a paragraph boundary or segment
  313.     boundary; a paragraph is a unit of 16 bytes. The segment value
  314.     of an address is such a segment paragraph, but divided by 16.
  315.  
  316.     It is easiest to work in the hexadecimal system. A paragraph
  317.     boundary in that case always ends with a zero and dividing by 16
  318.     then simply results in removal of the zero. In this way the
  319.     screen memory of a color adapter begins at segment &HB800, which
  320.     is address &HB8000.
  321.  
  322.     In contrast to the segment that represents an absolute address
  323.     (from the start of memory) the offset is a relative address.
  324.     That is because this measures the number of bytes from a segment
  325.     paragraph. Suppose we have a segmented address &H1E34:&H038A,
  326.     than we can calculate the corresponding absolute address by
  327.     adding the offset &H38A to the segment paragraph &H1E340. The
  328.     result is &H1E7CA, that is decimal 124874. It will be clear that
  329.     an absolute address can be represented by many different
  330.     segmented addresses. Every segment paragraph less than 64 Kb
  331.     below it can be used as a base. The just calculated address, for
  332.     instance, can also be referenced as &H1E33:&H039A, or as
  333.     &H1E7C:&H000A.
  334.  
  335.     The segmented address of a basic variable is obtained with the
  336.     basic functions VARSEG for its segment and VARPTR for its
  337.     offset. However, to obtain the offset of strings of variabele
  338.     length you must use SADD (that is "StringADDress") in stead of
  339.     VARPTR. The basic commands acting on a memory address, PEEK,
  340.     POKE and CALL ABSOLUTE, only use the offset part. The segment
  341.     has to be set previously with DEF SEG = <segment>. Ordinary
  342.     basic variables (except arrays) are all located in the default
  343.     data segment. Unless you did set another segment before, the
  344.     default data segment does not need to be set, but it is safer to
  345.     do it nevertheless. Anyway QBASIX assumes the segment is always
  346.     been set, also in case the default data segment is concerned.
  347.     The default data segment is set with the command DEF SEG as
  348.     such.
  349.  
  350.     Both segment and offset can assume values from 0 to 65535
  351.     inclusive. As far as size goes these numbers fit in an integer,
  352.     although integers range from -32768 to 32767 inclusive.
  353.     Therefore you can safely assign segments and offsets to integer
  354.     variables, as long as you do not do calculations with them. If
  355.     you want to do that you have to do it by way of long integers.
  356.  
  357.     More about the memory of a PC and the way it has to be
  358.     approached you will find in Peter Nortons book "Inside the IBM
  359.     PC Revised and Enlarged", published by Brady Books, a division
  360.     of Simon & Schuster Inc.
  361.  
  362.  
  363.     6. Using QBASIX together with certain software for system and
  364.        task management
  365.     -------------------------------------------------------------
  366.  
  367.     Below an outline is sketched of some situations in which QBasiX
  368.     TSR does not function properly, and an indication is given of
  369.     how to avoid the problem. This list certainly is not exhausting.
  370.     It is based only on my own experiences so far.
  371.  
  372.     4DOS.COM
  373.     --------
  374.     If QBasiX TSR is loaded inside a secundary or lower 4DOS shell
  375.     it has to be unloaded before returning to the parent shell.
  376.     Otherwise it stays behind in memory inactively. When it is
  377.     loaded low it also renders a part of memory useless for
  378.     programs.
  379.     COMMAND.COM does not pose this problem. However, in that case
  380.     also it is better not to load QBasiX TSR low inside a secundary
  381.     shell, because the memory available for programs decreases more
  382.     or even much more than necessary for QBasiX TSR only.
  383.  
  384.     NORTON Commander with 4DOS.COM
  385.     ------------------------------
  386.     In case you use the NORTON Commander together with 4DOS.COM,
  387.     QBasiX TSR does not function if you load it from inside the
  388.     commander. Therefore load QBasiX TSR before you start the NORTON
  389.     commander.
  390.  
  391.     DOSSHELL
  392.     --------
  393.     If QBasiX TSR is loaded high inside a DOSSHELL task by means of
  394.     the switch /h, it has to be unloaded before termination of that
  395.     task. Otherwise it stays behind in memory inactively. If, on the
  396.     contrary, QBasiX TSR is loaded low or is loaded high with
  397.     LOADHIGH, DOSSHELL takes care of unloading it.
  398.     You can load QBasiX TSR before starting DOSSHELL without a
  399.     problem. In that case it is available in every task started by
  400.     DOSSHELL.
  401.  
  402.     DESQView
  403.     --------
  404.     If QBasiX TSR is loaded before starting DESQView SetError does
  405.     not function inside DESQView. To have QBasiX TSR fully
  406.     functioning inside DESQView it has to be loaded in a DESQView
  407.     window.
  408.  
  409.  
  410.     8. Conclusion
  411.     -------------
  412.  
  413.     The full QBASIX package for QBASIC includes:
  414.  
  415.     - QBASIX.EXE: the TSR, the program for loading the assembler
  416.       routines in memory;
  417.     - QBASIX.BAS: the programming framework for using QBASIX;
  418.     - QBASIX.PRO: the basic procedures of QBASIX together with their
  419.       declarations of variable types and constants;
  420.     - QBASIX.LST: a list of all procedures, grouped with respect to
  421.       their area of operation;
  422.     - QBASIX.DOC: documentation by procedure;
  423.     - QBASIX.MAN: this manual;
  424.     - QBABS.QLB en QBABS.LIB: a quick library and matching normal
  425.       library for using QBASIX with QuickBasic 4.x.
  426.  
  427.     All these are collected in one zip file with the name
  428.     QBASIX.ZIP.
  429.  
  430.     Let me know when you encounter an problem in using QBASIX. In
  431.     case this is due to an error in the source code, I shall try to
  432.     fix that error. I welcome constructive criticism and suggestions
  433.     for improvement.
  434.  
  435.     You can reach me by mail at my home address:
  436.  
  437.     Hans Lunsing
  438.     Klaproos 38
  439.     2317 EL     LEIDEN
  440.     The Netherlands
  441.  
  442.     and by electronic mail at address:
  443.  
  444.         Internet:        jlunsing@doge.nl
  445.         Fidonet:         2:281/607.214
  446.  
  447.